/*
File:		Emitter.h
Author:		Skyler Suzuki
Purpose:	CEmitter class handles the Flyweight pattern 
			and particles that belong to the emitter
*/

#pragma once
#include <string>
#include <list>

class CParticle;
class CEntity;

enum	EmitterShape {EMITTER_RECT, EMITTER_CIRCLE, EMITTER_LINE, EMITTER_POINT };

struct particleColor
{
	int pCR;
	int pCG;
	int pCB;
	int pCA;
};

class CEmitter
{
public:
	CEmitter(void);
	~CEmitter(void);

	bool Update(float fElapsedTime);
	void Render(void);

	void Explosion(void);
	void AddRef( void );
	void Release( void );

	CParticle* GenerateParticle(void);


	// Mutators
	void	SetEmitterShape	(EmitterShape eEmitterShape);
	void	SetIsLooping			(bool bIsLooping);
	void	SetVelocityStartX		(float fVelocityStartX);
	void	SetVelocityEndX			(float fVelocityEndX);
	void	SetVelocityStartY		(float fVelocityStartY);
	void	SetVelocityEndY			(float fVelocityEndY);
	void	SetScaleStart			(float fScaleStart);
	void	SetScaleEnd				(float fScaleEnd);
	void	SetEmissionRate			(float fEmissionRate);
	void	SetRotationStart		(float fRotationStart);
	void	SetRotationEnd			(float fRotationEnd);
	void	SetMinLife				(int nMinLife);
	void	SetMaxLife				(int nMaxLife);
	void	SetShape				(int nShape);
	void	SetMaxParticles			(int nMaxParticles);
	void	SetImageID				(int nImageID);
	void	SetStartColor			(particleColor colorStart);
	void	SetEndColor				(particleColor colorEnd);
	void	SetParticleName			(std::string sParticleName);
	void	SetFileName				(std::string sFileName);
	void	SetEntityPosParticle	(CEntity	*entityPosParticle);
							
	// Accessors
	EmitterShape	GetEmitterShape(void) const;
	bool			GetIsLooping(void) const;
	float			GetVelocityStartX(void) const;
	float			GetVelocityEndX(void) const;
	float			GetVelocityStartY(void) const;
	float			GetVelocityEndY(void) const;
	float			GetScaleStart(void) const;
	float			GetScaleEnd(void) const;
	float			GetEmissionRate(void) const;
	float			GetRotationStart(void) const;
	float			GetRotationEnd(void) const;
	int				GetMinLife(void) const;
	int				GetMaxLife(void) const;
	int				GetShape(void) const;
	int				GetMaxParticles(void) const;
	int				GetImageID(void) const;
	particleColor	GetStartColor(void) const;
	particleColor	GetEndColor(void) const;
	std::string		GetParticleName(void) const;
	std::string		GetFileName(void) const;
	CEntity*		GetEntityPosParticle(void) const;

private:
	EmitterShape			m_eEmitterShape;
	bool					m_bIsLooping;
	float					m_fVelocityStartX;
	float					m_fVelocityEndX;
	float					m_fVelocityStartY;
	float					m_fVelocityEndY;
	float					m_fScaleStart;
	float					m_fScaleEnd;
	float					m_fEmissionRate;
	float					m_fSpawnTime;
	float					m_fRotationStart;
	float					m_fRotationEnd;
	int						m_nMinLife;
	int						m_nMaxLife;
	int						m_nShape;
	int						m_nMaxParticles;
	int						m_nImageID;
	particleColor			m_colorStart;
	particleColor			m_colorEnd;
	std::string				m_sParticleName;
	std::string				m_sFileName;
	std::list<CParticle*>	m_listLiveParticles;
	std::list<CParticle*>	m_listDeadParticles;
	CEntity*				m_entityPosParticle;

	// reference count
	unsigned int			m_unRefCount;
};

